import { useState, useEffect, useLayoutEffect } from "react";

async function queryData(){
    const data=await new Promise((resolve)=>{
        setTimeout(()=>{
            resolve(100)
        },2000)
    })
    return data
}

function App() {
    const [num, setNum] = useState(1)

    useLayoutEffect(() => {
        console.log('useLayoutEffect')
        // queryData().then(data =>{
        //     setNum(data)
        // })
        setNum(2)
    }, [num])

    return (
        <div>
            <button onClick={() => setNum(num + 1)}>{num}</button>
        </div>
    )
}

export default App;